#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
    int a = 0;
    int b = 0;
    scanf("%d %d", &a, &b);
    int arr1[1000] = { 0 };
    int arr2[1000] = { 0 };
    int i = 0;
    for (i = 0; i < a; i++)
    {
       scanf("%d", &arr1[i]);
    }
    for (i = 0; i < b; i++)
    {
      scanf("%d", &arr2[i]);
    }
    int arr3[200] = { 0 };
    for (i = 0; i < a + b; i++)
    {
      if (i < a)
        arr3[i] = arr1[i];
      else
        arr3[i] = arr2[i - a];
    }
    for (i = 0; i < a + b - 1; i++)
    {
      int j = 0;
      for (j = 0; j < a + b - 1 - i; j++)
      {
        if (arr3[j] > arr3[j + 1])
        {
            int t = arr3[j];
            arr3[j] = arr3[j + 1];
            arr3[j + 1] = t;
        }
      }
    }
    for (i = 0; i < a + b; i++)
    {
      printf("%d ", arr3[i]);
    }
    return 0;
}